package com.xuecheng.content.controller;

import com.xuecheng.api.content.CourseAuditApi;
import com.xuecheng.api.content.model.CourseBaseDTO;
import com.xuecheng.api.content.model.qo.QueryCourseModel;
import com.xuecheng.api.content.model.vo.CourseAuditVO;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.common.util.SecurityUtil;
import com.xuecheng.content.convert.CourseBaseConvert;
import com.xuecheng.content.service.CourseBaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * - @author by 姜暄煊
 * - @Date 12.13
 * - @Description
 */
@RestController
@Slf4j
public class CourseAudController implements CourseAuditApi {

    public static final Long OPERATION_FLAG = -99887799L;

    @Autowired
        private CourseBaseService courseBaseService;

    //
    @PostMapping("m/course/list")
    public PageVO queryCourseList(PageRequestParams params, @RequestBody QueryCourseModel model) {
        PageVO pageVO = courseBaseService.queryCourseList(params, model, OPERATION_FLAG);
        return pageVO;
    }
    //
    @PostMapping("m/courseReview/approve")
    public void approveCourse(@RequestBody CourseAuditVO auditVO) {
        CourseBaseDTO dto = CourseBaseConvert.INSTANCE.vo2toDto(auditVO);
        courseBaseService.approve(dto);

    }
}
